<template>
	<view class="ljapp">
		<view class="content">
			<view class="report-file u-flex u-flex-y-center" v-for="(item,index) in group.list" :key="index">
				<view class="inner u-flex-fill u-flex u-flex-y-center" @click="onSelect(item)">
					<image src="/static/lj/common/group_712.png" mode="aspectFill"></image>
					<view>
						<view class="tit">{{item.name}}</view>
						<view class="time">{{$u.timeFormat(item.createtime,"yyyy-mm-dd hh:MM")}}2022-03-12 10:00</view>
					</view>
				</view>
			</view>
			
			<lj-empty v-if="group.loaded&&group.list.length<=0">暂无报告</lj-empty>
			<view v-else>
				<u-loadmore
					:status="loading?'loading':(group.loaded?'nomore':'loadmore')"
					fontSize="28rpx"
					color="#d9d9d9"
					nomoreText="已加载全部"
					marginTop="30rpx"
					marginBottom="0"
					@loadmore="getList"
				></u-loadmore>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				group:{
					page: 1,
					limit: 10,
					list: [],
					loaded: false,
				},
				loading: false,
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			init(){
				this.group.page = 1
				this.group.list = []
				this.group.loaded = false
				this.loading = false
			
				this.getList();
			},
			getList(){
				var that = this, group = that.group;
				if(that.loading || group.loaded) return;
			
				that.loading = true
			
				this.$Http({
					url: 'getReportSelect',
					data: {
						page: group.page,
						limit: group.limit,
					},
					type:'POST',
				}).then(res=>{
					if(res.code == 1){
						var list = res.data;
						group.loaded = list.length < group.limit;
						group.page ++;
						group.list = group.list.concat(list);
					}
					
					that.loading = false
				}).catch(()=>{
					that.loading = false
				});
			},
			onReachBottom(){
				this.getList()
			},
			onSelect(item){
				console.log('onSelect',item)
				this.$store.commit('selectReportobj', item)
				
				uni.navigateBack({})
			}
		}
	}
</script>

<style lang="less">
	@import '@/pagesL/style.less';
	
	.content{
		padding: 20rpx;
	}
	.report-file{
		.inner{
			border: none;
			margin-bottom: 20rpx;
			box-shadow: 0 4rpx 6rpx #eee;
		}
	}
</style>
